package com.gitee.wsl.security.rbac

import com.gitee.wsl.struct.category.CategoryItemWarp


open class Subject(var name: String){

    companion object{
        val DEFAULT= Subject("")
    }
}

class SubjectCategory(data: Subject): CategoryItemWarp(data){
    companion object{
        val ROOT_GROUP= SubjectCategory(Subject.DEFAULT)
    }
}




interface SubjectScope{
    var name:String

    fun permission(vararg permissionName:String)

    fun subject(subjectHandler: SubjectScope.()->Unit)
}

class SubjectScopeImp: SubjectScope {
    override var name: String = ""

    var permissionList:List<String>?=null

    var subjectScopeList = mutableListOf<SubjectScopeImp>()

    override fun permission(vararg permissionName: String) {
        permissionList = permissionName.asList()
    }

    override fun subject(subjectHandler: SubjectScope.() -> Unit) {
        val subSubjectScope= SubjectScopeImp()
        subjectHandler(subSubjectScope)
        subjectScopeList.add(subSubjectScope)
    }

}
